<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_articles_category
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JHtml::_('bootstrap.framework');
$doc = JFactory::getDocument();
$app = JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();

$js = "(function($){
		
	$(document).ready(function(){
		$('#container').nested({ gutter: 0, minWidth: 198, });
		$('#container .box-section p').show();		
	})

	$(window).resize(function () {		
			console.log($('#blog-action').width());
		
			resize=$('#blog-action').width();
			if(resize<459){
				$('#container').animate({			
		           width: 300
		        }, function () { 
					$('#container').nested({ gutter: 1, minWidth: 145 });
					$('#container .box-section p').hide();
		        });
			}else if(resize>619 && resize<767){		
		        $('#container').animate({
		            width: 620
		        }, function () {
		            $('#container').nested({ gutter: 0, minWidth: 150, });
					$('#container .box-section p').hide();
		        });
		
			}else if(resize>767 && resize<1023){		
			  $('#container').animate({
		            width: 768
		        }, function () {
		            $('#container').nested({ gutter: 0, minWidth: 160, });
					$('#container .box-section p').hide();
		        });
			}
			else if(resize>1023 && resize<1189){		
			  $('#container').animate({
		            width: 1024
		        }, function () {
		            $('#container').nested({ gutter: 0, minWidth: 160, });
					$('#container .box-section p').show();
		        });
			}
			else if(resize>1190){							
				$('#container').animate({
		            width: 1190
		        }, function () {
		            $('#container').nested({ gutter: 0, minWidth: 198, });
					$('#container .box-section p').show();
		        });					
			}		
		});
		
		
})(jQuery);
		
			
		
		";

$doc->addScript($templateDir . '/js/jquery.nested.js');
$doc->addScript($templateDir . '/js/makeboxes.js');
$doc->addScriptDeclaration( $js );
?>
<div id="container" class="container">	
		
		<?php foreach ($list as $key=>$item) : ?>
			<?php 
				$images=json_decode($item->images);
				?>	
				<?php switch ($key+1):
				 case 3: ?>
					<?php if($params->get('image-intro')):?>		
							<div class="box size21">
								<a class="image-intro-full" href="<?php echo $item->link; ?>" style="background-image: url('<?php echo $params->get('image-intro');?>');"> 
								</a>
							</div>
						<?php endif;?>
					
					<div class="box size21">											
						<div class="section">
							<div class="box-section">
								<?php if ($params->get('link_titles') == 1) : ?>
									<h3>
									<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
										<?php echo $item->title; ?>
									</a>
									</h3>
								<?php else : ?>
									<h3><?php echo $item->title; ?></h3>
								<?php endif; ?>
								
								<?php if ($params->get('show_introtext')) : ?>
									<p>
										<?php echo $item->displayIntrotext; ?>
									</p>
								<?php endif; ?>
							</div>	
						</div>
						<a class="image-intro" href="<?php echo $item->link; ?>" style="background-image: url('<?php echo $images->image_intro;?>');"></a>		
					</div>	
					<?php break;?>
				<?php case 4:?>
					<div class="box size21">											
						<div class="section">
							<div class="box-section">
								<?php if ($params->get('link_titles') == 1) : ?>
									<h3>
									<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
										<?php echo $item->title; ?>
									</a>
									</h3>
								<?php else : ?>
									<h3><?php echo $item->title; ?></h3>
								<?php endif; ?>
								
								<?php if ($params->get('show_introtext')) : ?>
									<p>
										<?php echo $item->displayIntrotext; ?>
									</p>
								<?php endif; ?>
							</div>	
						</div>
						<a class="image-intro" href="<?php echo $item->link; ?>" style="background-image: url('<?php echo $images->image_intro;?>');"></a>		
					</div>	
					<?php break;?>
					
				<?php case 5:?>
					<div class="box size21">											
						<div class="section">
							<div class="box-section">
								<?php if ($params->get('link_titles') == 1) : ?>
									<h3>
									<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
										<?php echo $item->title; ?>
									</a>
									</h3>
								<?php else : ?>
									<h3><?php echo $item->title; ?></h3>
								<?php endif; ?>
								
								<?php if ($params->get('show_introtext')) : ?>
									<p>
										<?php echo $item->displayIntrotext; ?>
									</p>
								<?php endif; ?>
							</div>	
						</div>
						<a class="image-intro" href="<?php echo $item->link; ?>" style="background-image: url('<?php echo $images->image_intro;?>');"></a>		
					</div>	
					<?php break;?>
					
				<?php default:?>
				<div class="box size21">
					<a class="image-intro" href="<?php echo $item->link; ?>" style="background-image: url('<?php echo $images->image_intro;?>');"></a>							
					<div class="section">
						<div class="box-section">
							<?php if ($params->get('link_titles') == 1) : ?>
								<h3>
								<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
									<?php echo $item->title; ?>
								</a>
								</h3>
							<?php else : ?>
								<h3><?php echo $item->title; ?></h3>
							<?php endif; ?>
							
							<?php if ($params->get('show_introtext')) : ?>
								<p>
									<?php echo $item->displayIntrotext; ?>
								</p>
							<?php endif; ?>
						</div>	
					</div>
				</div>
				<?php endswitch;?>
		
		<?php endforeach; ?>	
</div>
